package com.custom.base.common.view

import android.content.Context
import android.util.AttributeSet
import com.ashokvarma.bottomnavigation.BottomNavigationBar
import com.ashokvarma.bottomnavigation.BottomNavigationItem
import com.custom.base.R


/**
 * 底部导航栏
 * @author 王永吉
 * @date 2019/7/3 10:46
 */
class BottomNavBar : BottomNavigationBar {
    @JvmOverloads
    constructor(
        context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
    ) : super(context, attrs, defStyleAttr)

    init {
        //首页
        val msg = BottomNavigationItem(R.mipmap.msg_bottom_green, "消息")
            .setActiveColorResource(R.color.bottom_green)
            .setInactiveIconResource(R.mipmap.msg_bottom_black)
            .setInActiveColorResource(R.color.bottom_black)
        //首页
        val address = BottomNavigationItem(R.mipmap.address_book_bottom_green, "通讯录")
            .setActiveColorResource(R.color.bottom_green)
            .setInactiveIconResource(R.mipmap.address_book_bottom_black)
            .setInActiveColorResource(R.color.bottom_black)
        //首页
        val find = BottomNavigationItem(R.mipmap.find_bottom_green, "发现")
            .setActiveColorResource(R.color.bottom_green)
            .setInactiveIconResource(R.mipmap.find_bottom_black)
            .setInActiveColorResource(R.color.bottom_black)
        //首页
        val user = BottomNavigationItem(R.mipmap.user_bottom_green, "我的")
            .setActiveColorResource(R.color.bottom_green)
            .setInactiveIconResource(R.mipmap.user_bottom_black)
            .setInActiveColorResource(R.color.bottom_black)
        //设置底部导航模式及样式(主要)
        setMode(MODE_FIXED)
        setBackgroundStyle(BACKGROUND_STYLE_STATIC)
        setBarBackgroundColor(R.color.bottom_white)
        //添加Tab(主要)
        addItem(msg)
            .addItem(address)
            .addItem(find)
            .addItem(user)
            .setFirstSelectedPosition(0)
            .initialise()
    }

}
